<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            安灯处理
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">

        <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
            <ul class="aui-list aui-form-list" style="margin-top: 1%;overflow-y: auto; ">
                <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">处理措施</div>

                        <div class="aui-list-item-input">
                            <select id="exceptionMeasure"></select>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">备注</div>

                        <div class="aui-list-item-input">
                            <input type="text" id="remark" class="aui-input" onclick="getIdSelector();" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">处理人</div>

                        <div class="aui-list-item-input">
                            <input type="text" id="handlId" class="aui-input" onclick="getIdSelector();" />
                        </div>
                    </div>
                </li>

                <!-- <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">物料编码</div>

                        <div class="aui-list-item-input">
                            <input type="text" disabled placeholder="物料编码" id="mrlCode" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">异常内容编码</div>

                        <div class="aui-list-item-input">
                            <input type="text" disabled placeholder="异常内容编码" id="exceptionContentCode" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">异常内容名称</div>

                        <div class="aui-list-item-input">
                            <input type="text" disabled placeholder="异常内容名称" id="exceptionContentName" />
                        </div>
                    </div>
                </li>

                <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">异常描述</div>

                        <div class="aui-list-item-input">
                            <input type="text" disabled placeholder="异常描述" id="exceptionRemark" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">异常处理措施</div>

                        <div class="aui-list-item-input">
                            <select id="exceptionMeasureGid">
                            </select>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" id="chkmrlQtyItem">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 200px;">备注</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="请输入备注" id="remark" />
                        </div>
                    </div>
                </li> -->
            </ul>
            <div style="display: flex;
                         justify-content: space-around;
                         padding-top: 10px;
                         padding-bottom: 10px;">
                <div class="aui-btn aui-btn-info" style="width:30%;margin-top:2%;" onclick="closeWin()">取消
                </div>
                <div class="aui-btn aui-btn-info" style="width:30%;margin-top:2%;" onclick="changeState()">确定
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var ids = "";
    var taskId = "";
    var remark = "";
    var exceptionTypeGid = "";
    var exceptionMeasure = "";
    var handlId = "";
    var code = "";
    //初始化
    apiready = function () {
        code = api.pageParam.code;
        exceptionTypeGid = api.pageParam.exceptionTypeGid;
        ids = api.pageParam.id;  // 获取 'id' 字段的值
        taskId = api.pageParam.taskId;  // 获取 'taskId' 字段的值
        $("#exceptionTypeCode").val(api.pageParam.exceptionTypeCode);
        $("#exceptionTypeName").val(api.pageParam.exceptionTypeName);
        $("#opCode").val(api.pageParam.opCode);
        $("#mrlCode").val(api.pageParam.mrlCode);
        $("#exceptionContentCode").val(api.pageParam.exceptionContentCode);
        $("#exceptionContentName").val(api.pageParam.exceptionContentName);
        $("#exceptionRemark").val(api.pageParam.exceptionRemark);
        $("#remark").focus();
        idSelector = "remark";
        getComBox()
    }

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }

    function getComBox() {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getUtilComboxList";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                un: un,
                tablename: "usm_exception_measure",
                column_name: "name",
                column_value: "sysid",
                condition: "exception_type_gid = '" + exceptionTypeGid + "'",
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            async: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var map = eval("(" + data + ")");
                var list = eval(map.list);
                var html = "";
                for (var i = 0; i < list.length; i++) {
                    html += "<option value='" + list[i].value + "'>" + list[i].label + "</option>";
                }
                $api.html($api.byId("exceptionMeasure"), html);
            }
        });
    }

    function changeState() {
        remark = $("#remark").val();
        exceptionMeasure = $("#exceptionMeasure").val();
        handlId = $("#handlId").val();
        if (exceptionMeasure == null || exceptionMeasure == "" || exceptionMeasure == undefined) {
            api.toast({
                msg: '请选择处理措施！',
                duration: 3000
            });
            return;
        }

        if (handlId == null || handlId == "" || handlId == undefined) {
            api.toast({
                msg: '请录入处理人！',
                duration: 3000
            });
            return;
        }
        var un = localStorage.getItem("un");
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getAssemblyAndonHandle";

        api.showProgress({
            title: '保存中...',
        });

        var data = {
            values: {
                exceptionCode: code,
                handlId: handlId,
                remark: remark,
                exceptionMeasureId: exceptionMeasure,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //返回成功
                if (myobj.code == "0") {

                    api.toast({
                        msg: "保存成功",
                        duration: 3000
                    });
                    api.closeWin();
                    api.execScript({
                        name: api.pageParam.name,
                        script: 'dealSuccess()'
                    });

                } else if (myobj.code == "1") {

                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    function doSearch(ids) {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getAnDonLaunchDetail";

        var data = {
            values: {
                id: ids,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //返回成功
                if (myobj.code == "0") {
                    var list = eval(myobj.list);
                    // console.log(list.problemResult)
                    $("#exceptionTypeCode").val(list.exceptionTypeCode);
                    $("#exceptionTypeName").val(list.exceptionTypeName);
                    $("#opCode").val(list.opCode);
                    $("#mrlCode").val(list.mrlCode);
                    $("#exceptionContentCode").val(list.exceptionContentCode);
                    $("#exceptionContentName").val(list.exceptionContentName);
                    $("#exceptionRemark").val(list.exceptionRemark);
                    // $("#remark").val(list.remark);
                    //失败
                } else if (myobj.code == "1") {
                    //清空表格数据
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //订单返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

<style>
    .c1 {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, .5);
        z-index: 99;
        margin-top: 0%;
    }

    .c2 {
        background-color: white;
        position: fixed;
        width: 400px;
        height: 300px;
        top: 50%;
        left: 50%;
        z-index: 100;
        margin-top: -125px;
        margin-left: -200px;
        padding-top: 2%;
        padding-left: 2%;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    .hide {
        display: none;
    }
</style>

</html>